package cn.hh.redis.controller;

import cn.hh.redis.annotation.CheckSmsCode;
import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author huangh
 * @date 2021/11/19
 * @Description:
 */
@RestController
@RequestMapping("/user")
public class UserController {

    private Logger logger = LoggerFactory.getLogger(UserController.class);


    @GetMapping("list")
    public String list(){
        String str = "====================";
        logger.trace("trace" + str);
        logger.debug("debug" + str);
        logger.info("info" + str);
        logger.warn("warn" + str);
        logger.error("error" + str);
        return "list";
    }

    @RequestMapping("index")
    public String index(@RequestBody(required=false) Map<String,Object> param,
                        @RequestParam(required=false)  Map<String,Object> param1,
                        @RequestHeader Map<String,Object> headParam){
        String result = "@RequestBody: " + JSON.toJSONString(param);
        result = result + "\n@RequestParam: " + JSON.toJSONString(param1);
        result = result + "\n@RequestHeader: " + JSON.toJSONString(headParam);
        return result;
    }

    @RequestMapping("data")
    @CheckSmsCode /**校验验证码通过**/
    public String data(@RequestBody(required=false) Map<String,Object> param,
                        @RequestParam(required=false)  Map<String,Object> param1,
                        @RequestHeader Map<String,Object> headParam){
        String result = "@RequestBody: " + JSON.toJSONString(param);
        result = result + "\n@RequestParam: " + JSON.toJSONString(param1);
        result = result + "\n@RequestHeader: " + JSON.toJSONString(headParam);

        return result;
    }

}
